<?php

namespace common\repositories\outstock;

use common\entities\outstock\MyscrmDeliveryAttachmentEntity;
use common\repositories\BaseRepository;

/**
 * Created by PhpStorm.
 * User: luoy03
 * Date: 16-12-12
 * Time: 上午11:00
 */
class DeliveryAttachmentRepository extends BaseRepository
{
    public static $businessPatternMap=['联营'=>2,'直属'=>1];
    public function addFile($data){
        $entity=new MyscrmDeliveryAttachmentEntity();
        $entity->load($data,'');
        $saveRes=$entity->save();
        if($saveRes===false){
            return self::setAndReturn(__LINE__,$entity->getAllFirstErrorMessage());
        }
        return $saveRes;
    }
    public function getByDeliveryGuid($deliveryGuid){
        return MyscrmDeliveryAttachmentEntity::find()
            ->where(['delivery_guid'=>$deliveryGuid])
            ->orderBy('created_on desc')
            ->asArray(true)
            ->all();
    }
}